package com.wondream.myframework.heima_concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 第三种创建线程的方法-实现Callable接口和FutureTask结合使用
 */
public class _004_Thread_Implements_Callable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable<Integer> callable = new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                return 100;
            }
        };
        FutureTask<Integer> var1 = new FutureTask<>(callable);
        Thread var2 = new Thread(var1, "thread1");
        var2.start();
        System.out.println("第四种创建线程的方式(实现Callable接口):" + var1.get());;
    }
}
